/**
 *  JFTSTool - Java Full Text Search tool.
 *  Copyright (C) <2009>  <grupo JFTS>
 *  This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jftstool.indexer;

import java.io.File;

import org.jftstool.exceptions.JFTSFrameworkException;
import org.jftstool.indexer.exceptions.JFTSIndexerException;

/**
 * @author grupo JFTS
 *
 */
public interface IJFTSIndexer {
	
	/**
	 * Add a single docuement file to the index
	 * By default when finish optimize the index
	 * @param file File that content document to index
	 * @throws JFTSIndexerException
	 * @throws JFTSFrameworkException 
	 */
	public void addDocument(File file) throws JFTSIndexerException, JFTSFrameworkException;
	
	/**
	 * Add a single docuement file to the index
	 * @param file
	 * @param optimizeIndex If equal true, after index file JFTS optimize the index
	 * @throws JFTSIndexerException
	 * @throws JFTSFrameworkException 
	 */
	public void addDocument(File file, boolean optimizeIndex) throws JFTSIndexerException, JFTSFrameworkException;;	
	
	/**
	 * Add a directory hierarchy to the index (Including sub-dirs)
	 * By default when finish optimize the index  
	 * @param directory
	 * @param ignoreErrors
	 * @throws JFTSIndexerException
	 * @throws JFTSFrameworkException 
	 */
	public void addDocuments(File directory, boolean ignoreErrors) throws JFTSIndexerException, JFTSFrameworkException;;
	
	
	/**
	 * Add documents to the index from dataBase source
	 * @param useConnection Connection to the database
	 * @param dbQuery Query to get documents from database
	 * @param ignoreErrors
	 * @throws JFTSIndexerException
	 * @throws JFTSFrameworkException
	 */
	public void addDBDocuments(String useConnection, String dbQuery, boolean ignoreErrors) throws JFTSIndexerException, JFTSFrameworkException;;
	
	
	/**
	* Remove one or more documents in the "field" have the courage id.
	* @param field column of the document which would proceed to remove
	* @param id identifies the key value or to delete documents
	* @return returns the number of documents deleted
	 * @throws JFTSIndexerException
	 * @throws JFTSFrameworkException 
	 */
	public long deleteDocument(String field, String id) throws JFTSIndexerException, JFTSFrameworkException;;
}
